home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / rga / rga1.frm < prev    next >
Text File  |  1995-12-05  |  4KB  |  196 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    Caption         =   "I Love WinApps!"
  4.    ClientHeight    =   3960
  5.    ClientLeft      =   990
  6.    ClientTop       =   1950
  7.    ClientWidth     =   6525
  8.    Height          =   4650
  9.    Icon            =   RGA1.FRX:0000
  10.    Left            =   930
  11.    LinkMode        =   1  'Source
  12.    LinkTopic       =   "Form1"
  13.    ScaleHeight     =   3960
  14.    ScaleWidth      =   6525
  15.    Top             =   1320
  16.    Width           =   6645
  17.    Begin Menu FileMenuNull 
  18.       Caption         =   "&File"
  19.       Begin Menu FileMenuAbout 
  20.          Caption         =   "&About"
  21.          Shortcut        =   {F1}
  22.       End
  23.       Begin Menu FileMenuFiller1 
  24.          Caption         =   "-"
  25.       End
  26.       Begin Menu FileMenuExit 
  27.          Caption         =   "E&xit"
  28.       End
  29.    End
  30. End
  31. '
  32. ' This has variables germane to multiple procedures in the
  33. ' form. Otherwise, Visual Basic would have each form having
  34. ' its own variables.
  35. '
  36. Dim FirstTimeThrough As Integer
  37. Dim ResizeOnly As Integer
  38.  
  39. Sub FileMenuAbout_Click ()
  40. '
  41. ' This runs when the user requests "File, About":
  42. '
  43. ' Build a message.
  44. '
  45.     A$ = "The " + Chr$(34) + ILWA$ + Chr$(34) + " Program" + Chr$(13) + Chr$(10) + "by Charles L. Perrin"
  46. '
  47. ' Display the message.
  48. '
  49.     MsgBox A$, 64, ILWA$
  50. '
  51. End Sub
  52.  
  53. Sub FileMenuExit_Click ()
  54. '
  55. ' This executes when the user does the Exit request:
  56. '
  57.     End
  58. '
  59. ' and that's all, folks!
  60. '
  61. End Sub
  62.  
  63. Sub Form_Click ()
  64. '
  65. ' This is invoked every time a mouse click is in the window.
  66. '
  67.     Dim FontMax, FontNo, THW, THH As Integer
  68. '
  69. ' Clear the screen.
  70. '
  71.     Cls
  72. '
  73. ' Don't switch fonts if we're only redrawing.
  74. '
  75.     If Not (ResizeOnly) Then
  76. '
  77. ' Is not the first time through?
  78. '
  79.         If Not (FirstTimeThrough) Then
  80. '
  81. ' Get number of fonts currently defined for the screen.
  82. ' (The number of screen fonts can change on the fly!)
  83. '
  84.             FontMax = Screen.FontCount
  85. '
  86. ' This begins a loop that obtains candidate fonts, and
  87. ' throws out the ones that aren't text!
  88. '
  89.             Do
  90. '
  91. ' Come up with a random font number.
  92. '
  93.                 FontNo = Int(FontMax * Rnd(1))
  94. '
  95. ' Get the font name.
  96. '
  97.                 ProposedFontName$ = Screen.Fonts(FontNo)
  98. '
  99. ' Convert the font name to upper case for matching ease.
  100. '
  101.                 ProposedFontUC$ = UCase$(ProposedFontName$)
  102. '
  103. ' I'm not going to let this loop exit on three cases:
  104. '   DINGBAT fonts, SYMBOL fonts, or the DIGITAL (Clock) font.
  105. '
  106.             Loop Until ((InStr(ProposedFontUC$, "DINGBAT") = 0) And (InStr(ProposedFontUC$, "SYMBOL") = 0) And (ProposedFontUC$ <> "DIGITAL"))
  107. '
  108. ' Set the font name to the proposed font name.
  109. '
  110.             FontName = ProposedFontName$
  111. '
  112. ' Or, is this the first time through?
  113. '
  114.         Else
  115. '
  116. ' First time through - use the first font (SYSTEM, usually).
  117. '
  118.             FontName = Screen.Fonts(0)
  119. '
  120.         End If
  121. '
  122.     End If
  123. '
  124. ' Set the font size to 12 points.
  125. '
  126.     FontSize = 12
  127. '
  128. ' Determine half the text width.
  129. '
  130.     THW = TextWidth(ILWA$) / 2
  131. '
  132. ' Determine half the text height.
  133. '
  134.     THH = TextHeight(ILWA$) / 2
  135. '
  136. ' Set the X, Y screen position to center the text.
  137. '
  138.     CurrentX = ScaleWidth / 2 - THW
  139.     CurrentY = ScaleHeight / 2 - THH
  140. '
  141. ' Print the text "I Love WinApps!"
  142. '
  143.     Print ILWA$
  144. '
  145. ' Indicate that the resize is finished.
  146. '
  147.     ResizeOnly = False
  148. '
  149. ' Indicate that this isn't the first time through.
  150. '
  151.     FirstTimeThrough = False
  152. '
  153. End Sub
  154.  
  155. Sub Form_Load ()
  156. '
  157. ' This gets executed when the module loads:
  158. '
  159. ' Seed the random number generator.
  160. '
  161.     Randomize
  162. '
  163. ' Indicate that the form is to automatically redraw.
  164. '
  165.     AutoRedraw = True
  166. '
  167. ' Indicate that this is the first time through.
  168. '
  169.     FirstTimeThrough = True
  170. '
  171. ' Simulate the initial click to bring up the text.
  172. '
  173.     Form_Click
  174. '
  175. End Sub
  176.  
  177. Sub Form_Resize ()
  178. '
  179. ' This gets entered if the user's been playing with that
  180. ' big fat border and resizing this puppy!
  181. '
  182. ' Clear the screen.
  183. '
  184.     Cls
  185. '
  186. ' Indicate that only a resize operation is to take place.
  187. '
  188.     ResizeOnly = True
  189. '
  190. ' Simulate a form click and let that finish the job!
  191. '
  192.     Form_Click
  193. '
  194. End Sub
  195.  
  196.